import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsNotEmpty, IsNumber, IsOptional } from 'class-validator';
import { BaseTenantDto } from './base-tenant.dto';

export class SendMessagesDto extends BaseTenantDto {
  @ApiProperty({
    description: '消息接收者的手机号',
    example: '13616859570',
  })
  @IsOptional({ message: '消息接收者的手机号不能为空' })
  receivePhone?: string;
  @ApiProperty({
    description: '消息接收者的openId',
    example: '13616859570',
  })
  @IsNotEmpty({ message: '消息接收者的openId不能为空' })
  receive_id?: string;
  @ApiProperty({
    description: '消息类型',
    example: 'text',
  })
  @IsNotEmpty({ message: '消息类型不能为空' })
  @IsEnum(['text', 'interactive'])
  msg_type: string;
  @ApiProperty({
    description: '消息应用类型',
    example: 'mini',
  })
  @IsOptional()
  @IsEnum(['h5', 'mini'])
  program_type?: string;
  [propsName: string]: any;
}

export class SendMessagesToUserDto extends SendMessagesDto {
  @ApiProperty({
    description: '消息类型',
    example: 'text',
  })
  @IsNotEmpty({ message: '消息类型不能为空' })
  msg_type: string;
  @ApiProperty({
    description: '纯文本消息内容',
    example: 'test content111',
  })
  @IsNotEmpty({ message: '消息内容不能为空' })
  content: string;
}

export class SendCardMessagesToUserDto extends SendMessagesDto {
  @ApiProperty({
    description: '消息类型',
    example: 'interactive',
  })
  @IsNotEmpty({ message: '消息类型不能为空' })
  msg_type: string;
}

export class SendInteractiveMessagesDto extends SendMessagesDto {
  @ApiProperty({
    description: '消息类型',
    example: 'text',
  })
  @IsNotEmpty({ message: '消息类型不能为空' })
  msg_type: 'interactive';
  @ApiProperty({
    description: '消息应用类型',
    example: 'mini',
  })
  @IsNotEmpty({ message: '消息应用类型不能为空' })
  @IsEnum(['h5', 'mini'])
  program_type?: string;
  @ApiProperty({
    description: '跳转url',
    example: '',
  })
  @IsOptional()
  url?: string;
  @ApiProperty({
    description: 'appId',
    example: '',
  })
  @IsOptional()
  appId?: string;
  [propsName: string]: any;
}
